clear all;

% top view region of AVM image
Region_TL_X = 21;
Region_TL_Y = 8;
Region_BR_X = 339;
Region_BR_Y = 466;

IMG_Height = 459;
IMG_Width = 319;

% Each camera's position in the top view image (cropped image)
F_CAM_X = 160;  F_CAM_Y = 80;
L_CAM_X = 113;  L_CAM_Y = 161;
R_CAM_X = 208;  R_CAM_Y = 161;
B_CAM_X = 160;  B_CAM_Y = 324;


% select DB
DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB0_V-Static_O-Single\'; image_num = 497;
% DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB1_V-Static_O-Two\';    image_num = 3592;
% DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB2_V-Parking_O-Single\';    image_num = 2405;
% DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB3_V-Parking_O-Single\';    image_num = 2809;
% DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB4_V-Static_O-Three\';    image_num = 1726;
% DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB5_V-Static_O-Three\';    image_num = 3143;
% DB_name = 'C:\01_Work\02_Dev\01_PH_MOD\DB\DB6_V-Static_O-Three\';    image_num = 3725;


for i = 3 : image_num
    % Load two successive image
    cur_img_name = [DB_name, int2str(i), '.jpg'];         cur_img = imread(cur_img_name);
    pre_img_name = [DB_name, int2str(i-2), '.jpg'];       pre_img = imread(pre_img_name);
    figure_name = ['PH_Result_', int2str(i), '.jpg'];
    
    % Crop image
    cur_crop_img = cur_img(Region_TL_Y:Region_BR_Y, Region_TL_X:Region_BR_X, :);
    pre_crop_img = pre_img(Region_TL_Y:Region_BR_Y, Region_TL_X:Region_BR_X, :);
    
    hsv_img = rgb2hsv(cur_crop_img);

    subplot(1,2,1);
    imshow(cur_crop_img); axis on; title('crop image');
    subplot(1,2,2);
    imagesc(hsv_img(:,:,3)); title(['hue ', int2str(i)]);
    pause(0.1);
end
